package by.pavlyukevich.paymentsystem.datamodel;

import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;

import by.pavlyukevich.paymentsystem.datamodel.card.Card;
import by.pavlyukevich.paymentsystem.datamodel.user.UserAccount;

@Entity
public class Account extends AbstractEntity<Integer> {

	@Column
	@NotNull
	@Min(value = 1000000000000L)
	@Max(value = 9999999999999L)
	private Long accountNumber;

	@Column
	@Min(value = 0)
	private Double balance;

	@Column
	@NotNull
	private Boolean isBlocked;

	@ManyToOne(fetch = FetchType.LAZY)
	@NotNull
	private UserAccount userAccount;

	@OneToMany(mappedBy = "account", cascade = { CascadeType.ALL }, orphanRemoval = true)
	private Set<Card> cards;

	public Long getAccountNumber() {
		return accountNumber;
	}

	public void setAccountNumber(Long accountNumber) {
		this.accountNumber = accountNumber;
	}

	public Double getBalance() {
		return balance;
	}

	public void setBalance(Double balance) {
		this.balance = balance;
	}

	public Boolean getIsBlocked() {
		return isBlocked;
	}

	public void setIsBlocked(Boolean isBlocked) {
		this.isBlocked = isBlocked;
	}

	public UserAccount getUserAccount() {
		return userAccount;
	}

	public void setUserAccount(UserAccount userAccount) {
		this.userAccount = userAccount;
	}

	public Set<Card> getCards() {
		return cards;
	}

	public void setCards(Set<Card> cards) {
		this.cards = cards;
	}

}
